import sys
import re

logfilename = sys.argv[1]
print "analizing >>", logfilename, "<< ..."

finish_token = "Finish"
current_token = "current"
current_pid_pattern = "[-+]?\d+"
current_pid_re = re.compile(current_pid_pattern)


file = open(logfilename, "r")
pmap = {}


while True:
	line = file.readline()
	if 0 == len(line):
		break
	if -1 == line.find(finish_token):
		continue
	for token in line.split():
		if -1 == token.find(current_token):
			continue
		pid = re.findall(current_pid_pattern, token)[0]
		if not pid in pmap:
			pmap[pid] = 0
		else:
			pmap[pid] += 1

file.close()
print 'There were %d tasks in total and committed switching for %d times' % (len(pmap), sum(pmap.values()))

for task in pmap:
	print "task(pid=%s) was scheduled for %s times" % (task, pmap[task])




